package com.atguigu.springcloud.fallback;

import com.atguigu.springcloud.commons.entities.Result;
import com.atguigu.springcloud.entities.Dept;
import com.atguigu.springcloud.service.DeptService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author horay
 * @category Class description
 * @email horay_hyc@qq.com
 * @date 2018/6/12 23:11
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptService> {

    @Override
    public DeptService create(Throwable throwable) {
        return new DeptService() {
            @Override
            public Result add(Dept dept) {
                return Result.ok();
            }

            @Override
            public Result edit(Dept dept) {
                return Result.ok();
            }

            @Override
            public Result delete(Long deptNo) {
                return Result.ok();
            }

            @Override
            public Result getByDeptNo(Long deptNo) {
                Dept dept = new Dept(deptNo, "client:dept not found hystrix", "client:no database found");
                return Result.ok(dept);
            }

            @Override
            public Result findAll() {
                return Result.ok();
            }

            @Override
            public Result discovery() {
                return Result.ok();
            }
        };
    }
}
